package edu.mcw.rgd.clinminer.web.ui;

import com.vaadin.ui.Table;

import org.apache.log4j.Logger;

import com.vaadin.spring.roo.addon.annotations.RooVaadinEntityView;

import edu.mcw.rgd.clinminer.web.AbstractEntityView;
import edu.mcw.rgd.clinminer.web.EntityEditor;
import edu.mcw.rgd.clinminer.web.EntityTableColumnGenerator;

@RooVaadinEntityView(formBackingObject = edu.mcw.rgd.clinminer.domain.Participant.class)
public class ParticipantView extends AbstractEntityView<edu.mcw.rgd.clinminer.domain.Participant> {
	private static final Logger log = Logger.getLogger(ParticipantView.class);

    @Override
    protected EntityEditor createForm() {
        return new ParticipantForm();
    }

    @Override
    protected void configureTable(Table table) {
        table.setContainerDataSource(getTableContainer());
        table.setVisibleColumns(getTableColumns());

        setupGeneratedColumns(table);
    }

	@Override
	public Object[] getTableColumns() {
		// log.debug("Available properties to display: " +
		// super.getTableColumns());

		String[] props = new String[] { "name", "studies" };
		return props;
	}

	public void setupGeneratedColumns(Table table) {
		table.removeGeneratedColumn("studies");
		table.addGeneratedColumn("studies", new EntityTableColumnGenerator(
				"name"));
    }
}
